package com.tangji.signaltower.runners;

import com.tangji.signaltower.utils.SpringUtils;
import com.tangji.signaltower.websocket.netty.NettyServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 * User: yujianfu (mr.vencnet@gmail.com)
 * Date: 2020-07-04
 * Time: 01:28
 */
@Component
public class SocketServerRunner implements CommandLineRunner {
    private static Logger logger = LoggerFactory.getLogger(SocketServerRunner.class);

    @Autowired
    private WarningListInit warningListInit;

    @Override
    public void run(String... strings) throws Exception {

        warningListInit.initWanningList();
        logger.info("SocketServerRunner 完成名单初始化");
        new Thread(() -> {
            logger.info("SocketServerRunner 启动server server");
            NettyServer nettyServer = SpringUtils.getBean(NettyServer.class);
            nettyServer.run();
        }).start();
    }
}
